import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';

class Data {
  final String url = 'http://pics.sc.chinaz.com/files/pic/pic9/202001/zzpic22334.jpg';
}

Future<Data> getData() async {
  await Future.delayed(Duration(seconds: 1));
  return Data();
}

class MyHomePage2 extends StatefulWidget {

  @override
  _MyHomePage2State createState() => _MyHomePage2State();
}

class _MyHomePage2State extends State<MyHomePage2> {
  final SlidableController slidableController = SlidableController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(""),
      ),
      body: ListView.builder(
        itemCount: 20,
        itemBuilder: (context, index) {
          return FutureBuilder<Data>(
            future: getData(),
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                return Slidable(
                  actionPane: SlidableScrollActionPane(),
                  actionExtentRatio: 0.25,
                  secondaryActions: <Widget>[
                    IconSlideAction(
                      caption: 'Delete',
                      color: Colors.red,
                      icon: Icons.delete,
                      //onTap: () => removeLocation(location),
                    ),
                  ],
                  child: Container(
                    padding: EdgeInsets.only(left: 10,right: 10),
                    child: ListTile(
                      // onTap: () {
                      //   Navigator.pushNamed(context, Routes.closeUp);
                      // },

                      leading: SizedBox(
                        width: 150.0,
                        height: 150.0,
                        child: ClipRRect(
                          borderRadius: BorderRadius.circular(20.0),
                          child: RepaintBoundary(
                            child: Image(
                              image: NetworkImage(snapshot.data.url),
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                );
              }
              return CircularProgressIndicator();
            },
          );
        },
      ),
    ); // This trailing comma makes auto-formatting nicer for build methods.
  }
}